/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.satyam.swingvalidator.commons;

import javax.swing.JComponent;
import javax.swing.JTextField;
import com.satyam.swingvalidator.core.Severity;
import com.satyam.swingvalidator.core.AbstractValidator;

/**
 *
 * @author assassin
 */
public class IsANumberValidator extends AbstractValidator {

    public IsANumberValidator() {
       
    }

    @Override
    protected Severity getValidationCriteria(JComponent c) {
        
        try {
            Integer.parseInt(((JTextField) c).getText());
        } catch (NumberFormatException e) {
            return new Severity(Severity.ERROR, "Please enter a valid number");
        }
        return new Severity(Severity.NO_ERROR, null);
    }
}
